ActionController::Routing::Routes.draw do |map|

  # The priority is based upon order of creation: first created -> highest priority.

  # Sample of regular route:
  #   map.connect 'products/:id', :controller => 'catalog', :action => 'view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  #   map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
  # This route can be invoked with purchase_url(:id => product.id)

  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   map.resources :products

  # Sample resource route with options:
  #   map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }

  # Sample resource route with sub-resources:
  #   map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller

########## ADMIN ROUTES ########################################################
    
    # Dashboard Route (Not a resource)
    map.connect 'admin/', :controller => 'admin/dashboard'
    # Profile Route (not handled as normal resource)
    map.connect 'admin/profile/:action', :controller => 'admin/profile'
    # Login Window
    map.connect 'admin/access/:action', :controller => 'account'
    # Settings Route
    map.connect 'admin/settings/:action', :controller => 'admin/settings'
    
    # Custom routes for doing 
    map.connect 'admin/videos/sync_vimeo', :controller => 'admin/videos', :action => 'sync_vimeo'
    map.connect 'admin/tags/cleanup', :controller => 'admin/tags', :action => 'cleanup'
    
    map.namespace :admin do |admin|
      
      admin.resources :announcements, :collection => { :auto_complete_for_tag_name => :post }
      admin.resources :pages, :collection => { :auto_complete_for_tag_name => :post }
      admin.resources :tags
      admin.resources :podcasts, :collection => { :auto_complete_for_tag_name => :post }
      admin.resources :app_questions, :collection => { :sort => :post }
      admin.resources :videos, :collection => { :auto_complete_for_tag_name => :post }
      
      admin.resources :users, :collection => { :transfer => :get } do |users|
        users.resources :permissions
      end
      admin.resources :albums, :collection => { :auto_complete_for_tag_name => :post } do |album|
        album.resources :photos
      end
    end
    
########## MAIN ROUTES #########################################################
  # SET A HOME ROUTE
  map.root :controller => 'announcements'
  
  # SEARCH
  map.connect 'search/:term', :action => 'find', :controller => 'search'
  map.connect 'search/:term.:format', :action => 'find', :controller => 'search'
  map.connect 'search', :action => 'find', :controller => 'search'
  
  # list view
  map.connect ':controller'
  map.connect ':controller.:format'
  # view to show an individual object as html as default
  map.connect ':controller/:id', :action => 'show'
  # view to show an individual object with a specified format
  map.connect ':controller/:id.:format', :action => 'show'
  # view to list items tagged with a given tag
  map.connect ':controller/tagged/:tag', :action => 'tagged'
  # view to list items tagged with a given tag in a specific format
  map.connect ':controller/tagged/:tag.:format', :action => 'tagged'
    
  # Specificaly for the hosing Application
  map.connect 'housing_application/submit', :controller => 'housing_application', :action => 'submit'
  # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
  # map.root :controller => "welcome"

  # See how all your routes lay out with "rake routes"

  # Install the default routes as the lowest priority.
  # map.connect ':controller/:action/:id'
  # map.connect ':controller/:action/:id.:format'
end
